const formatter = {
  'object': item => item instanceof Object ? item : {val: item, goto: '0'},
  'string': item => item instanceof Object ? item.val : item
}


/**
 * 
 * @param {*} optionStr 原始json字符串
 * @param {*} targetType 'string' | 'object'
 */
export default function optionParse(optionStr, targetType = 'string') {
  const options = JSON.parse(optionStr);
  
  return options.map(option => 
      formatter[targetType](option)
  )
}